home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / • Other Stuff / Scripting Aids / App Functional Scripting / TestLevel.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  5.6 KB  |  158 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    TestLevel.lib
  5. #
  6. #    Contains:    Task dispatching mechanism for application functional scripting,
  7. #                as well as tasks specific to performing functional tests.
  8. #
  9. #    Written by:    MF
  10. #
  11. #    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  12. #
  13. # ****************************************************************************
  14. #            C h a n g e        H i s t o r y (most recent first):
  15. # ****************************************************************************
  16. #
  17. #        Vers      Date        Author    Description
  18. #        ----    --------    ------    ---------------------------------------------
  19. #         1.0         5/23/95        MDF        Created
  20. #
  21. # ****************************************************************************
  22.  
  23. ########################################################################
  24. #                            External libraries 
  25. #=======================================================================
  26. Libraries "ExceptionHandling.Lib","UserInterface.Lib","OutPut.Lib";
  27.  
  28.  
  29. #########################################################################
  30. #                        TestTaskDispatcher(theList)
  31. #========================================================================
  32. # Author:        MDF
  33. # Description:    This routine generates and returns a randomized list from the
  34. #                first parameter
  35. # Parameters:    pQLTaskList        - a list of quicklook tasks
  36. #                pFunctTaskList  - a list of functional tests
  37. # Returns:        none
  38. # Examples:        TestTaskDispatcher({task DoText,task DoWindow},{task DoLineTool},1);
  39. #                TestTaskDispatcher({task DoText, {task DoDraw,1,[window o:1]},
  40. #                                   {task DoWindow}},{task DoLineTool},1);
  41. # Assumptions:    Supports calling a task with up to five arguments.
  42. #========================================================================
  43. # History:
  44. #    MDF        5/23/95        Created
  45. #########################################################################
  46. TASK TestTaskDispatcher(pQLTaskList := {},pFunctTaskList := {})
  47. begin
  48.     if(pFunctTaskList)
  49.     begin
  50.         newFunctTaskList := {};       # initialize
  51.         for taskNum := 1 to card(pFunctTaskList)      # loop through the number of tasks in pFunctTaskList
  52.         begin
  53.             flagIndex := isMember(1,pFunctTaskList[taskNum]);    # get the flag setting
  54.             if(flagIndex)    # if flag is true, remove flag and re-concatenate task list
  55.                 newFunctTaskList := newFunctTaskList + remove(2,pFunctTaskList[taskNum]);
  56.         end;
  57.         lookupTaskList := pQLTaskList + newFunctTaskList;    # concatenate quicklook and functional tasks
  58.     end;
  59.     else
  60.         lookupTaskList := pQLTaskList;
  61.         
  62.     for each randomTask in RandomList(lookupTaskList)
  63.     begin
  64.         if (typeof(randomTask) = 'list')    # if a task has arguments associated with it
  65.         begin
  66.             listSize := card randomTask;
  67.             switch listSize
  68.             begin
  69.                 case 2:        # task reference plus one argument
  70.                     call(randomTask[1],randomTask[2]);
  71.                 case 3:        # task reference plus two arguments
  72.                     call(randomTask[1],randomTask[2],randomTask[3]);
  73.                 case 4:        # task reference plus three arguments
  74.                     call(randomTask[1],randomTask[2],randomTask[3],
  75.                          randomTask[4]);
  76.                 case 5:        # task reference plus four arguments
  77.                     call(randomTask[1],randomTask[2],randomTask[3],
  78.                          randomTask[4],randomTask[5]);
  79.                 case 6:        # task reference plus five arguments
  80.                     call(randomTask[1],randomTask[2],randomTask[3],
  81.                          randomTask[4],randomTask[5],randomTask[6]);
  82.                 case 7:        # task reference plus 6 arguments
  83.                     call(randomTask[1],randomTask[2],randomTask[3],
  84.                          randomTask[4],randomTask[5],randomTask[6],
  85.                          randomTask[7]);
  86.             end;
  87.         end;
  88.         else    # task without arguments
  89.         begin
  90.             println;
  91.             call(randomTask);
  92.             println;
  93.         end;
  94.     end;
  95. end; # TestTaskDispatcher
  96.  
  97.  
  98. #########################################################################
  99. #                        RandomList(theList)
  100. #========================================================================
  101. # Author:        MDF
  102. # Description:    This routine generates and returns a randomized list from the
  103. #                first parameter
  104. # Parameters:    pTheList        - any list
  105. # Returns:        randomizedList    - a new randomized list
  106. # Examples:        newList := RandomList({item1,item2,item3});
  107. # Assumptions:    None
  108. #========================================================================
  109. # History:
  110. #    MDF        5/23/95        Created
  111. #########################################################################
  112. TASK RandomList(pTheList)
  113. begin
  114.     randomizedList := {};
  115.     
  116.     while pTheList
  117.     begin
  118.         randomIndex := random(1, card pTheList);
  119.         randomizedList := randomizedList + {pTheList[randomIndex]};
  120.         pTheList := remove(randomIndex, pTheList);
  121.     end;
  122.     
  123.     return (randomizedList);
  124. end; # RandomList
  125.  
  126.  
  127. #########################################################################
  128. #                        ConvertToRelative(pPointList, pDocWind)
  129. #========================================================================
  130. # Author:        MDF
  131. # Description:    Accepts a point in global coordinates and converts it to
  132. #                coordinates relative to the window specified.
  133. # Parameters:    pPointList     - a list of points
  134. #                pDocWind    - window descriptor
  135. # Returns:        List of points.
  136. # Examples:        ConvertToRelative({50,100},[window t:'Untitled' o:1]);
  137. # Assumptions:    None
  138. #========================================================================
  139. # History:
  140. #    MDF        5/23/95        Created
  141. #########################################################################
  142. TASK ConvertToRelative(pPointList, pDocWind := [window o:1])
  143. begin
  144.     returnVal := 0;        # Init error condition
  145.     
  146.     windDesc := FindWindow(pDocWind);
  147.     if windDesc
  148.     begin
  149.         windRect := windDesc.r;
  150.         horizWindOffset := windRect[1];
  151.         vertWindOffset := windRect[2];
  152.         relCoord := {pPointList[1]-horizWindOffset,
  153.                      pPointList[2]-vertWindOffset};    # this line does the conversion
  154.         returnVal := relCoord;
  155.     end;
  156.     
  157.     return(returnVal);
  158. end; # ConvertToRelative